#include <stdio.h>
#include <string.h>


struct ddf
{
	char pp[256];
	int n;
}group[500];
int top;
int oper[256]; // 0 for ( , 1 for + , 2 for - , 3 for * ,4 for )


char sin[300];


void count()
{
	int i,j,a,b;
	int flag;
	int type;

	group[0].n=0;
	memset(group[0].pp,0,sizeof(group[0].pp));
	
	b=top--;
	a=top--;
	type=oper[oper[0]--];
	if (type==1)
	{
		group[0]=group[a];
		for (j=0;j<group[b].n;j++)
		{
			flag=0;
			for (i=0;i<=group[a].n;i++)
				if (group[b].pp[j]==group[a].pp[i])					
				{
					flag=1;
					break;
				}
			if (flag==0)
			{
				group[0].pp[group[0].n++]=group[b].pp[j]; //????????????????????
			}			
		}
	}
	else if (type==2)
	{
		for (i=0;i<group[a].n;i++)
		{
			flag=0;
			for (j=0;j<group[b].n;j++)
				if (group[a].pp[i]==group[b].pp[j])
				{
					flag=1;
					break;
				}
			if (flag==0)
			{
				group[0].pp[group[0].n++]=group[a].pp[i];
			}
		}
	}
	else if (type==3)
	{
		for (i=0;i<group[a].n;i++)
		{
			flag=0;
			for (j=0;j<group[b].n;j++)
				if (group[a].pp[i]==group[b].pp[j])
				{
					flag=1;
					break;
				}
			if (flag==1) //??????????????
			{
				group[0].pp[group[0].n++]=group[a].pp[i];
			}
				
		}
			
	}
	group[++top]=group[0];
	

	

	
}


main()
{
	int len, i, j;
	int a,b;
	char ch;
	while (scanf("%s",sin)!=EOF)
	{		
		if ( (len=strlen(sin)) == 0) continue;
		//init;
		memset(oper,0,sizeof(oper));
		memset(group,0,sizeof(group));
		top=0;
		oper[++oper[0]]=0;

		for (i=0;i<len;i++)
		{
			ch=sin[i];
			if (ch=='{')
			{
				a=i+1;
				while (sin[a]!='}') a++;
				top++;
				strncpy(group[top].pp,sin+i+1,a-i-1);
				group[top].n=a-i-1;
				i=a;
			}
			else if (ch=='(')
			{
				oper[++oper[0]]=0;
			}
			else if (ch==')')
			{
				while (oper[oper[0]]!=0) 
				{
					count(); 
				}
				oper[0]--;
			}
			else if (ch=='-')
			{
				while (oper[oper[0]]==1 || oper[oper[0]]==2 || oper[oper[0]]==3)
				{
					count();
					
				}oper[++oper[0]]=2;
			}
			else if (ch=='+')
			{
				while (oper[oper[0]]==1 || oper[oper[0]]==2 || oper[oper[0]]==3)
				{
					count();					
				}
				oper[++oper[0]]=1;
			}
			else if (ch=='*')
			{
				while (oper[oper[0]]==3)
				{
					count();					
				}oper[++oper[0]]=3;
			}


		}
		while (oper[oper[0]]!=0) 
			count();
		for (i=0;i<group[1].n;i++)
			for (j=i+1;j<group[1].n;j++)
				if (group[1].pp[i]>group[1].pp[j])
				{
					ch=group[1].pp[i];
					group[1].pp[i]=group[1].pp[j];
					group[1].pp[j]=ch;
				}
		printf("{");
		for (i=0;i<group[1].n;i++)
			printf("%c", group[1].pp[i]);
		printf("}\n");


	}
	return 0;
}
